<template>
	<view>
		<view class="goods-list">
			<view @click="geToShop(item)" v-for="(item,i) in goodsList" :key="i">
				<gy-goods :goods="item"></gy-goods>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLoding:true,
				queryObj: {
					query: '',
					cid: '',
					page: 1,
					pagesize: 10,
				},
				total: 0,
				goodsList: []
			};
		},
		methods: {
			geToShop(item){
				console.log(item.goodsId)
				uni.navigateTo({
					url:'/subpackage/shops/shops?goodId=' + item.goodsId
				})
			},
			async getGoodsList(cb) {
				this.isLoding = true
				const {
					data
				} = await uni.$http.get('http://192.168.1.11:8080/get/search', this.queryObj)
				cb && cb()
				this.isLoding = false
				this.goodsList = [...this.goodsList,...data.result]
			}

		},
		onPullDownRefresh() {
			this.queryObj.page = 1
			this.isLoding = false
			this.goodsList = []
			this.getGoodsList(()=>uni.stopPullDownRefresh())
		},
		onReachBottom() {
			this.queryObj.page ++
			console.log("page add : ",this.queryObj.page)
			if(this.isLoding){
				return
			}
			this.getGoodsList()
		},
		onLoad(options) {
			this.queryObj.cid = options.cid || ''
			this.queryObj.query = options.query || ''
			this.getGoodsList()
		}
	}
</script>

<style lang="scss">


</style>